package com.liuxl.db.tool;

import com.liuxl.db.common.Constants;

/**
 * 数据库工具类（简单工厂模式）
 * Created by LiuXiaoLong at 2021年1月8日
 */
public class DatabaseToolFactory {

	private static final MySQLDatabaseTool MYSQL_TOOL = new MySQLDatabaseTool();
	private static final SQLServerDatabaseTool SQLSERVER_TOOL = new SQLServerDatabaseTool();
	private static final OracleDatabaseTool ORACLE_TOOL = new OracleDatabaseTool();
	
	public static DatabaseTool getTool(String dbType) {
		switch (dbType) {
			case Constants.DbType.MYSQL:
				return MYSQL_TOOL;
			case Constants.DbType.SQL_SERVER:
				return SQLSERVER_TOOL;
			case Constants.DbType.ORACLE:
				return ORACLE_TOOL;
		}
		throw new IllegalStateException("Dbtype not matcher");
	}
}
